home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_12_07
/
allison
/
destroy3.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-02
|
410b
|
30 lines
LISTING 7 - Illustrates a Dangling Resource
// destroy3.cpp
#include <stdio.h>
void f(char *fname);
main()
{
try
{
f("file1.dat");
}
catch(...)
{}
return 0;
}
void f(char *fname)
{
FILE *fp = fopen(fname,"r");
if (fp)
{
// Use f, then throw an exception
throw 1;
fclose(fp); // This won't happen
}
}